home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / games / IndiZone / gold / seaMethods.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  2.8 KB  |  104 lines

  1. /*
  2.  * The original copyright owners of the accompanying source code files have
  3.  * agreed to place such code into the public domain.  Accordingly, anyone
  4.  * who receives or obtains a copy of such source code is freely entitled to
  5.  * reproduce, use and otherwise exploit such code (including the right to
  6.  * make derivative works), at his/her own risk and expense, without any
  7.  * obligation or liability to the original copyright owners.
  8.  *
  9.  * We would appreciate (but do not require) that the following message be
  10.  * included in any derivative works:
  11.  *
  12.  * "Portions of this program were developed by Peter Broadwell, Rob Myers
  13.  * and Robin Schaufler while working in Silicon Valley."
  14.  *
  15.  * The accompanying source code files and related documentation materials
  16.  * are distributed on an "AS IS" basis, without any warranties or
  17.  * guarantees of any kind.  All implied warranties, including the implied
  18.  * warranties of merchantability and of fitness for any particular purpose,
  19.  * are expressly disclaimed.
  20.  */
  21. #include <math.h>
  22. #include "gl.h"
  23. #include "device.h"
  24. #include "geom.h"
  25. #include "class.h"
  26. #include "classIds.h"
  27. #include "selectors.h"
  28. #include "mbox.h"
  29. #include "individual.h"
  30. #include "behavior.h"
  31. #include "doers.h"
  32. #include "colors.h"
  33. #include "objIds.h"
  34.  
  35. #include "sea.h"
  36.  
  37. #define PI 3.14159265358979323844
  38. #define DEG(x) ((float)x*(float)180/PI)
  39. #define RAD(x) ((float)x*PI/(float)180)
  40.  
  41. extern char frozen;
  42. extern char bullet;
  43.  
  44.  
  45. /* ARGSUSED */
  46. plantinit(s, argtype, univol)
  47.     register individual *s;
  48.     int argtype;
  49.     point *univol;
  50. {
  51.     register model *myModel;
  52.     register long i;
  53.     register float f;
  54.  
  55.     replicateModel(s);    /* first, instantiate and initialize the model */
  56.     myModel = s->descr;    /* use newly instantiated model */
  57.  
  58.     makeobj(LEAF);
  59.     rmvi(10,0,20);
  60.     rpmvi(0,0,0);
  61.     rpdri(0,0,19);
  62.     rpdri(100,0,0);
  63.     rpdri(0,0,-19);
  64.     rpdri(-100,0,0);
  65.     pclos();
  66.     closeobj();
  67.  
  68.     makeobj((Object)myModel);
  69.     pushLongName(s);
  70.     backface(FALSE);
  71.     fishWritemask(BACKGROUND);
  72.     fishColor(myModel->color);
  73.     pushmatrix();
  74.  
  75.     scale(6.0,6.0,4.5);
  76. /*
  77.  WIMP came into being to get the seaweed to stand up
  78.  straight on the early GT's. Without it it tended to look all bent over
  79.  and WIMPY.
  80.  I don't know what changed in the GL at that time but it seems to be
  81.  needed for all latter machines.
  82.  Take it out if you want to get things to run under "old" GL's.
  83.  It is also used in bubMethods.c, eggMethods.c and pebMethods.c
  84.  always as an inline define (to keep the Makefile simpler).
  85. */
  86. #define WIMP
  87. #ifdef WIMP
  88.         rotate(900, 'y');
  89. #endif /* WIMP */
  90.     movei(0,0,0);
  91.     for(i=0; i < ((sea *)s)->length; i++) {
  92.         f = i;
  93.         rotate((Angle)(5689 * sin(f*2) * cos(f*3)), 'z');
  94.         callobj(LEAF);
  95.     }
  96.     popmatrix();
  97.     backface(TRUE);
  98.     popLongName();
  99.     closeobj();
  100.     myModel->compiled = TRUE;
  101.     myModel->component = (Object)myModel;
  102. }
  103.  
  104.